<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="cw" uri="/widget-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
  	//模拟字典缓存
  	java.util.Map dic = new java.util.HashMap();
  	dic.put("dicSex", "[[1,'男'],[2,'女']]");
  	application.setAttribute("dic", dic);
  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<cw:base />
		<script type="text/javascript">
			function getSexData() {
				return [ [ 1, '男' ], [ 2, '女' ] ];
			}
			
			function showImage(v,m,r) {
		 		return "<img src=<s:url value='/'/>" + v + "></img>";
		  	}
		</script>
	</head>
	<body>
		<ul>
			<li>
				<cw:fieldSet title="可编辑表格" content="editGrid1Div" collapsible="true" collapsed="false"/>
				<div id="editGrid1Div">
					<cw:editGrid id="editGrid1" title="" url="${pageContext.request.contextPath }/sample/grid/grid.query.action"
				  		exportable="false" enablePage="false" selectMode="checkbox" urlParams="{id:0}" stripeRows="true" 
				  		stripleColor="#DBEEF4" autoLoad="true" loadMask="true" forceFit="true" pageSize="5">
				  		<cw:toolBar>
				  			<cw:actionButton type="add" title="添加" split="true"></cw:actionButton>
				  			<cw:actionButton type="delete" title="删除" split="true" url="${pageContext.request.contextPath }/sample/grid/editgrid.delete.action" 
				  			    waitMsg="正在删除数据..."/>
				  			<cw:actionButton type="remove" title="移除(统一删除)" split="true"/>
				  			<cw:actionButton type="update" title="保存" split="true" url="${pageContext.request.contextPath }/sample/grid/editgrid.update.action" 
				  			    waitMsg="正在保存数据..."/>
				  			<cw:actionButton type="" action="alert('总记录:'+Ext.getCmp('editGrid1').getStore().getTotalCount());" 
				  			    title="记录总数"/>
				  			<%-- <cw:actionButton type="copy" title="复制"/>--%>
				  		</cw:toolBar>
				  		<cw:indexColumn indexWidth="60"/>
				   		<cw:gridColumn property="name" editable="true" editorType="string" sortable="true" width="10%" title="姓名" 
				   		    defaultValue="huyunming" align="center"/>
				   		<cw:gridColumn property="email" editable="true" editorType="email"  sortable="true" width="20%" title="邮箱"
				   		    defaultValue="huyunming@wondersgroup.com" align="center"/>  		
				  		<cw:gridColumn property="age" editable="true"  sortable="true" width="10%" dataType="float" defaultValue="20" format="1--$" title="时薪" align="center">
				  			<cw:number property="age" allowDecimals="true" allowNegative="false" decimalPrecision="2"/>	 
				  		</cw:gridColumn>
				  		<cw:gridColumn property="birthday" editable="true"  sortable="true" width="15%" dataType="date" editorType="date"  title="生日" 
				  		    format="Y-m-d" defaultValue="1982-01-29T00:00:00" align="center"/>
				  		<cw:gridColumn property="brother" editable="true" width="20%" title="亲属" align="center">
				  			<cw:gridSelect property="brother" fields="['id','name']" width="100%"
									url="${pageContext.request.contextPath }/sample/form/loadGridSelectData.action" title="人员结果列表"
									displayField="name" valueField="name" pageSize="5" listWidth="400" >
									<cw:gridSelectColumn width="150" property="id" header="编号" />
									<cw:gridSelectColumn width="244" property="name" header="姓名" />
							</cw:gridSelect>
				  		</cw:gridColumn> 
				  		<cw:gridColumn property="sex" dataType="code" format="dicSex" editable="true"  sortable="true" width="8%" title="性别" 
				  		    editorType="int" defaultValue="1" align="center">
				  			<cw:combobox property="sex" data="[[1,'男'],[2,'女']]"/>
				  		</cw:gridColumn> 
				  		<cw:gridColumn property="created" title="创建时间" editable="true"  width="200" dataType="date" editorType="datetime" 
				  		    defaultValue="2016-04-16T01:00:00" align="center"/>
				  	</cw:editGrid>
				</div>
			</li>
		</ul>
		<cw:theme></cw:theme>
		<script type="text/javascript">
			Ext.onReady(function(){
				var STORE1 = Ext.getCmp('editGrid1').store;
				STORE1.on("load",function(s,r,o){
					resetHeight("editGridFrame");
			    });
				resetHeight("editGridFrame");
			})
		
			function resetHeight(frame) {
				var ifm = parent.document.getElementById(frame);
				var obj = document.body;
				var oStyle = obj.currentStyle? obj.currentStyle : window.getComputedStyle(obj, false);
				var initHeight = parseInt(document.body.clientHeight+parseInt(oStyle["margin-top"])+parseInt(oStyle["margin-bottom"]));
				ifm.height = parseInt(initHeight)+200;
			}
		</script>
	</body>
</html>